<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title></title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="">
        <script src="js/echarts.js"></script>
    </head>
    <body>
        <div id="chart" style="width: 800px; height: 600px; margin: 0 auto"></div>

    <script>
        const chart = echarts.init(document.getElementById('chart'));

        // 在前面添加const初始化你的值
        const days = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'];
        const visits = [320, 402, 431, 398, 520, 630, 710];

        const pieData = []; // 这里是存储转换后的数据
        for (let i = 0; i < days.length; i++) {
            pieData.push({
                name: days[i],
                value: visits[i]
            });
        }

        // 配置项
        const option = {
            title: {
                text: '{a|一周每天的访问量份额占比——你的学号}',
                link: 'https://www.baidu.com',
                target: 'self',
                left: 'center',
                textStyle: {
                    fontSize: 16,
                    color: '#333',
                    rich: {
                        a: {
                            textDecoration: 'underline',
                            cursor: 'pointer'
                        }
                    }
                }
            },
            series: [{
                type: 'pie',
                data: pieData, // 使用循环处理后的数据
                radius: '60%',
                label: {
                    show: true,
                    formatter: '{b}: {d}%'
                }
            }]
        };

        chart.setOption(option);
    </script>
    </body>
</html>